<template>
	<view class="s-plist">
		<view class="sw-item" v-for="p in plist" :key="p.pid">
			<navigator url="/pages/product/product">
				<image :src="$server_pic+p.ppic" mode="widthFix"></image>
				<text class="pname">{{p.pname}}</text>
				<text>￥{{p.pprice}}</text>
			</navigator>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			type: Number
		},
		name: "home-plist",
		data() {
			return {
				plist: []
			};
		},
		created() {
			this.$request({
				url: '/product/home/'+this.type+'/1/4',
				success: (res) => {
					this.plist = res.data.records;
				}
			})
		}
	}
</script>

<style>
	.s-plist {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: space-around;
	}

	.sw-item {
		width: 48%;
		background-color: white;
		margin: 16rpx 0;
		border-radius: 16rpx;
		overflow: hidden;
	}

	.sw-item navigator {
		display: flex;
		flex-direction: column;
	}

	.sw-item image {
		width: 100%;
	}

	.sw-item text {
		text-align: center;
		font-size: 28rpx;
		line-height: 56rpx;
	}

	.pname {
		width: 100%;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
</style>